package hhs.poc.activities.whoiswho;

import hhs.poc.activities.R;
import hhs.poc.util.utils;

import java.util.HashMap;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.CheckBox;
import android.widget.TextView;

public class Whoiswho extends Activity {
	Employee employee;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		initComponents();
		
		employee = utils.retrieveEmployee();
		setWhoiswho(employee);
	}
	
	@Override
	public void onBackPressed(){
//		Menu.backPressed();
		super.onBackPressed();
	}

	private void initComponents() {
		utils.setTitleBackgroundColor(findViewById(android.R.id.title));
		setContentView(R.layout.whoiswho);
	}

	public void setWhoiswho(Employee employee) {
		// TextViews
		TextView name = (TextView) findViewById(R.id.name);
		TextView job = (TextView) findViewById(R.id.job);
		TextView email = (TextView) findViewById(R.id.email);
		TextView academy = (TextView) findViewById(R.id.academy);
		TextView phone = (TextView) findViewById(R.id.phone);
		TextView room = (TextView) findViewById(R.id.room);

		// CheckBoxes
		CheckBox monday1 = (CheckBox) findViewById(R.id.monday1);
		CheckBox monday2 = (CheckBox) findViewById(R.id.monday2);
		CheckBox monday3 = (CheckBox) findViewById(R.id.monday3);
		CheckBox tuesday1 = (CheckBox) findViewById(R.id.tuesday1);
		CheckBox tuesday2 = (CheckBox) findViewById(R.id.tuesday2);
		CheckBox tuesday3 = (CheckBox) findViewById(R.id.tuesday3);
		CheckBox wednesday1 = (CheckBox) findViewById(R.id.wednesday1);
		CheckBox wednesday2 = (CheckBox) findViewById(R.id.wednesday2);
		CheckBox wednesday3 = (CheckBox) findViewById(R.id.wednesday3);
		CheckBox thursday1 = (CheckBox) findViewById(R.id.thursday1);
		CheckBox thursday2 = (CheckBox) findViewById(R.id.thursday2);
		CheckBox thursday3 = (CheckBox) findViewById(R.id.thursday3);
		CheckBox friday1 = (CheckBox) findViewById(R.id.friday1);
		CheckBox friday2 = (CheckBox) findViewById(R.id.friday2);
		CheckBox friday3 = (CheckBox) findViewById(R.id.friday3);

		// set TextViews
		name.setText(employee.getName());
		job.setText(employee.getJob());
		email.setText(employee.getEmail());
		academy.setText(employee.getAcademy());
		phone.setText(employee.getPhone());
		room.setText(employee.getRoom());

		HashMap<String, Boolean[]> present = employee.getPresentAsHashMap();

		Boolean[] monday = present.get("monday");
		Boolean[] tuesday = present.get("tuesday");
		Boolean[] wednesday = present.get("wednesday");
		Boolean[] thursday = present.get("thursday");
		Boolean[] friday = present.get("friday");

		// set CheckBoxes
		monday1.setChecked(monday[0]);
		monday2.setChecked(monday[1]);
		monday3.setChecked(monday[2]);
		tuesday1.setChecked(tuesday[0]);
		tuesday2.setChecked(tuesday[1]);
		tuesday3.setChecked(tuesday[2]);
		wednesday1.setChecked(wednesday[0]);
		wednesday2.setChecked(wednesday[1]);
		wednesday3.setChecked(wednesday[2]);
		thursday1.setChecked(thursday[0]);
		thursday2.setChecked(thursday[1]);
		thursday3.setChecked(thursday[2]);
		friday1.setChecked(friday[0]);
		friday2.setChecked(friday[1]);
		friday3.setChecked(friday[2]);
	}
}
